﻿Imports System.IO
Public Class Startup

    Dim fs As New FS
    Dim com As New Common
    Private Sub Startup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

    End Sub

    Private Sub Startup_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        ' Allow form to load
        com.sleep(1)
template:
        Dim templates As New Templates
        ProgressText.Text = "Scanning for Templates..."
        If (Directory.Exists(fs.Startup + "Templates")) Then
            Trace.WriteLine("[-] Loading Templates")
            templates.loadTemplates()
            Trace.WriteLine("[-] Loaded Templates")
            Progress.Increment(10)

plugin:
            ProgressText.Text = "Loading Plugins..."

            If (Directory.Exists(fs.Startup + "Plugins")) Then
                Trace.WriteLine("[-] Loading Plugins")
                Dim plugin As New Plugins
                plugin.loadPlugins()
                Trace.WriteLine("[-] Loaded Plugins")
            Else
                ProgressText.Text = "Creating Plugin directory..."
                fs.makeDir("Plugins")
                'debug
                Trace.WriteLine("[+]DIR:Plugins")
                GoTo plugin
            End If
        Else
            ProgressText.Text = "Creating Templates..."
            fs.makeDir("Templates")
            templates.generate()
            'debug
            Trace.WriteLine("[+]DIR:Templates")
            GoTo template
        End If
        Progress.Increment(Progress.Value + 75)
        ProgressText.Text = "Wrapping up..."
        'debug
        Trace.WriteLine("[!] Finished")
        Trace.Flush()
        'nothing to load. RELEASE THE KRAKEN!!!
        Progress.Value = 100
        com.sleep(2)
        'here goes main app form
        'as for now:
        Project.Show()
        Me.Hide()
    End Sub
End Class
